package com.neko.Thread_Learning.t16_No_synchronized_Demo;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * 测试 JUC 安全类型 の 集合
 * */
public class Test_JUC {
    public static void main(String[] args) {

        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<>();

        for (int i=0; i<10000; i++) {
            new Thread( () -> {
                list.add(Thread.currentThread().getName());
            });
        }

        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(list.size());

    }
}
